home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 October
/
PCWorld_2006-10_cd.bin
/
domacnost a kancelar
/
winorganizer
/
WinOrg.exe
/
PluginsAndCOM
/
Plugins
/
Demo
/
fTree.pas
< prev
Wrap
Pascal/Delphi Source File
|
2005-07-06
|
2KB
|
79 lines
unit fTree;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, ComObj, ExtCtrls;
type
TfrmTree = class(TForm)
TreeView1: TTreeView;
Panel1: TPanel;
Button1: TButton;
private
{ Private declarations }
function AddNode(AParent: TTreeNode; const AText: String; ID: Integer): TTreeNode;
procedure AddDoc(AParent: TTreeNode; ADoc: Variant);
public
{ Public declarations }
class procedure Execute;
end;
var
frmTree: TfrmTree;
implementation
{$R *.DFM}
{ TfrmTree }
class procedure TfrmTree.Execute;
var
WOrg, ADoc: Variant;
begin
WOrg := CreateOLEObject('WinOrganizer.App');
Application.Handle := WOrg.Handle;
with TfrmTree.Create(Application) do
try
if WOrg.FileList.ActiveIndex < 0 then
AddNode(nil, 'No file selected', 0)
else
begin
ADoc := WOrg.FileList.ActiveFile.Root;
AddDoc(nil, ADoc);
end;
if TreeView1.Items[0].Count > 0 then
TreeView1.Items[0].Expand(False);
ShowModal;
finally
Free;
end;
end;
function TfrmTree.AddNode(AParent: TTreeNode; const AText: String;
ID: Integer): TTreeNode;
begin
Result := TreeView1.Items.AddChildObject(AParent, AText, Pointer(ID));
end;
procedure TfrmTree.AddDoc(AParent: TTreeNode; ADoc: Variant);
var
i: Integer;
ANode: TTreeNode;
begin
if ADoc.isHidden then exit;
ANode := AddNode(AParent, ADoc.Text, ADoc.ID);
if ADoc.isAccessible then
for i := 0 to ADoc.NodeCount - 1 do
AddDoc(ANode, ADoc.Nodes[i]);
end;
end.